import { connect, useSelector, useDispatch, Link } from 'umi';
import { Button } from 'antd';

const Index = () => {
  const tags = useSelector((state: any) => {
    return state.tags;
  });
  const loading = useSelector((state: any) => state.loading).models.tags;
  const dispatch = useDispatch();
  const handlerClick = () => {
    dispatch({
      type: 'tags/fetchTagsList', // model的namespace / effects的名称
      payload: '参数1',
      payload2: '参数2',
    });
  };

  return (
    <div>
      dva学习
      <Link to="/admin/docs">去home</Link>
      <div>
        <Button onClick={handlerClick}>dispatch</Button>
      </div>
    </div>
  );
};

/**
 * @help 方式一
 * @function connect
 * @param 参数1 所有的model,返回值是需要的model,是一个object
 * **/
// export default connect(({ tags }: any) => ({
//   tags,
// }))(Index);

export default Index;
